package com.acme.bankapp.domain.bank;

public class Bank {
	private Client[] clients;	
	
	public Bank(){
		clients = new Client[10];
	}
	
	public void addClient(Client client){
		for (int i = 0; i < clients.length; ++i) {
			if (clients[i] == null) {
				clients[i] = client;
				return;
			}
		}
		System.out.println("Bank is full!"); // There will be an exception in next labs
	}
	
	public Client[] getClients() { 
		int clientCount = 0;
		for (Client cli : clients) {
			if (cli != null) {
				clientCount++;
			}
		}
		
		Client [] clientsCopied = new Client[clientCount];
		int currentClient = 0;
		
		for (Client cli : clients) {
			if (cli != null) {
				clientsCopied[currentClient++] = cli;
			}
		}
		return clientsCopied;
	}
}
